package cl.portal.escolares.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cl.portal.escolares.DAO.DAOPago;
import cl.portal.escolares.domain.Pago;

import com.opensymphony.xwork2.ActionSupport;

public class PagoDownloadComprobanteAction extends ActionSupport {
	/**
	 * 
	 */
	private static Log _log = LogFactory.getLog(PagoDownloadComprobanteAction.class);
	private static final long serialVersionUID = 1L;
	private Long pagoId;
	private Pago pago;
	private InputStream fileInputStream;
	 
	
	public String execute() throws Exception {
		try {
			pago=DAOPago.get(getPagoId());
		    fileInputStream = new FileInputStream(new File(pago.getRutaPDF()));
		    return "success";
		} catch (Exception e) {
			_log.error(e);
			return null;
		}
		
		
	}
	public void setFileInputStream(InputStream fileInputStream) {
		this.fileInputStream = fileInputStream;
	}
	public Long getPagoId() {
		return pagoId;
	}

	public void setPagoId(Long pagoId) {
		this.pagoId = pagoId;
	}
	
	public InputStream getFileInputStream() {
		return fileInputStream;
	}
	public Pago getPago() {
		return pago;
	}
	public void setPago(Pago pago) {
		this.pago = pago;
	}

}
